package com.example.springdemo;


import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.retry.ExponentialBackoffRetry;

import java.util.List;

/**
 * @Date 2023/4/16
 * @Author Jonathan
 */
public class CuratorDemo01 {
    public static void main(String[] args) throws Exception {
        // Curator
        ExponentialBackoffRetry retry = new ExponentialBackoffRetry(1000, 3, 3);
        CuratorFramework client = CuratorFrameworkFactory.newClient("192.168.17.100:2181", 30000, 30000, retry);
        client.start();
        long l = System.currentTimeMillis();
        List<String> strings = client.getChildren().forPath("/");
        for (String s : strings) {
            System.out.println("s--->" + s);
        }
        long l1 = System.currentTimeMillis();
        System.out.println("delta time is " + (l1 - l) / 1000 + "s");
        byte[] bytes = client.getData().forPath("/z1/z2");
    }
}
